package b4.model.vo.player
{
	public class Pack
	{
		public var equipList:Object;
		public var objList:Object;
		public var smithyObjList:Object;
		public var smithyEquipList:Object;
		
		public function Pack()
		{
			equipList = new Object();
			objList = new Object();
			smithyObjList = new Object();
			smithyEquipList = new Object();
		}
		
		public function reFreshSmithyItem(objList:Array):void
		{
			clearSmithy();
			for (var i:int = 0; i < objList.length;i++)
			{
				var basicObj:BasicObj = objList[i] as BasicObj;
				addNewSmithyItem(basicObj);
			}
			
		}
		private function addNewSmithyItem(objItem:BasicObj):void
		{
			if (objItem is Equip)
			{
				var equip:Equip = new Equip();
				equip.getObjCopy(objItem as Equip);
				smithyEquipList[equip.id] = equip;
			}
			else
			{
				var obj:Obj = new Obj();
				obj.getObjCopy(objItem as Obj);
				if (smithyObjList.hasOwnProperty(obj.index))
				{
					var smithyObj:Obj = smithyObjList[obj.index] as Obj;
					smithyObj.num += obj.num;
				}
				else
				{
					smithyObjList[obj.index] = obj;
				}
			}
		}

		private function clearSmithy():void
		{
			smithyObjList = new Object();
			smithyEquipList = new Object();
		}
		public function clearPackage():void
		{
			objList = new Object();
			equipList = new Object();
		}
	}
}